fix (utils) : [CRW-8603] Use slice of string instead of apimachinery Set to merge events#1711
Merged
michael-valdron merged 1 commit intodevfile:mainfrom May 7, 2025
Conversation
bb4d09e to
eca2e36
Compare
…Set to merge events We were previously using apimachinery Set that is internally based on Map, an unordered data structure. Due to this we were losing the original insertion order defined in the devfile while merging it, List() call returns the elements in non-deterministic order, as it internally ranges over the map. Use string slice to preserve insertion order of all event types. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
eca2e36 to
9923538
Compare
akurinnoy
approved these changes
May 6, 2025
Jdubrick
approved these changes
May 7, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: akurinnoy, Jdubrick, michael-valdron, rohanKanojia, thepetk The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Member
Author
|
Thanks a lot for the review! Is it possible to merge it? |
michael-valdron
pushed a commit
to michael-valdron/devfile-api
that referenced
this pull request
May 14, 2025
…Set to merge events (devfile#1711) We were previously using apimachinery Set that is internally based on Map, an unordered data structure. Due to this we were losing the original insertion order defined in the devfile while merging it, List() call returns the elements in non-deterministic order, as it internally ranges over the map. Use string slice to preserve insertion order of all event types. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description of Changes
We were previously using apimachinery Set that is internally based on Map, an unordered data structure. Due to this we were losing the original insertion order defined in the devfile while merging it,
List()call returns the elements in non-deterministic order, as it internally ranges over the map.Use string slice to preserve insertion order of all event types.
Related Issue(s)
https://issues.redhat.com/browse/CRW-8603
Acceptance Criteria
Testing and documentation do not need to be complete in order for this PR to be approved. However, tracking issues must be opened for missing testing/documentation.
New testing and documentation issues can be opened under
devfile/api/issues.You can check the respective criteria below if either of the following is true:
If criteria is left unchecked please provide an explanation why.
Unit/Functional tests
QE Integration test
Documentation
Client Impact
Tests Performed
I have added unit tests that verify that insertion order is preserved.
Before these changes, for a devfile that contained postStart events in order like this:
After merging, this order was altered like this:
After making these changes, order is preserved (check unit test files)
How To Test
You can run unit tests that are added for this change.
Notes To Reviewer
This change is required for a fix in devworkspace operator for an issue where postStart event order is different than specified: https://issues.redhat.com/browse/CRW-8603
While debugging, I found that we're using MergeDevWorkspaceTemplateSpec and it seems to be changing the order of
postStartevents.